<template>
  <div class="avue-sidebar">
    <logo></logo>
    <el-scrollbar style="height:100%">
      <div v-if="validatenull(menu)"
           class="avue-sidebar--tip">{{ $t('menuTip') }}
      </div>
      <el-menu ref="navmenu"
               :default-active="nowTagValue"
               mode="vertical"
               :default-openeds="defaultOpeneds"
               :show-timeout="200"
               :collapse="keyCollapse">
        <sidebar-item :menu="menu"
                      :screen="screen"
                      first
                      :props="website.menu.props"
                      :collapse="keyCollapse"></sidebar-item>
      </el-menu>
      <!--               :default-openeds=""-->
    </el-scrollbar>
  </div>
</template>

<script>
import {mapGetters} from "vuex";
import logo from "../logo";
import sidebarItem from "./sidebarItem";
import {BC_INDEX_URL} from "@/const/urlConst"
import {BC_LOGIN_URL} from "../../../const/urlConst";

export default {
  name: "sidebar",
  components: {sidebarItem, logo},
  inject: ["index"],
  data() {
    return {
      defaultOpeneds: [],
    };
  },
  created() {
    this.index.openMenu(this.menuId);
  },
  computed: {
    ...mapGetters(["website", "menu", "tag", "keyCollapse", "screen", "menuId"]),
    nowTagValue: function () {
      return this.$router.$avueRouter.getValue(this.$route);
    }
  },
  watch: {
    menu: {
      handler(val) {
        if (val) {
          this.menu.map((item, index) => {
            this.defaultOpeneds.push(item.path)
          })
        }
      }
    }
  },
  mounted() {},
};
</script>
